package org.dreamland.infrastructure.security

import com.google.code.kaptcha.Producer
import com.google.code.kaptcha.impl.DefaultKaptcha
import com.google.code.kaptcha.util.Config
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import java.util.*

@Configuration
class CaptchaConfig {

    @Bean
    fun captchaProducer(): Producer {
        val properties = Properties()
        properties.setProperty("kaptcha.image.width", "150")
        properties.setProperty("kaptcha.image.height", "50")
        properties.setProperty("kaptcha.textproducer.font.size", "40")
        properties.setProperty("kaptcha.textproducer.char.length", "4")

        val config = Config(properties)
        val defaultKaptcha = DefaultKaptcha()
        defaultKaptcha.config = config
        return defaultKaptcha
    }
}